public class Test4 {
    public static int removeElement(int[] nums, int val) {
        int left = 0;
        int right = nums.length;
        while(left<right){
            if(nums[left]!=val){
                left++;
            }else{
                nums[left]=nums[right-1];
                left++;
                right--;
            }
        }
        return left;
    }

    public static void main1(String[] args) {
        int[] arr={0,1,2,2,3,0,4,2};
        System.out.println(removeElement(arr, 2));
    }
    public static void rotate(int[] nums, int k) {
        int[] tmp=new int[k];
        for(int i=0;i<tmp.length;i++){
            tmp[i]=nums[nums.length-i-1];
        }
        for(int i=nums.length-1;i>=k;i--){
            nums[i]=nums[i-k];
        }
        for(int i=0;i<k;i++){
            nums[i]=tmp[k-i-1];
        }
    }

    public static void main(String[] args) {
        int[] arr={1,2,3,4,5,6,7};
        rotate(arr,3);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
